<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>人脸上传</title>
    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1" />
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="{{ url('/common/mobile-common/common.css') }}">
    <link rel="stylesheet" href="{{ url('mobile/css/member/bindTel.css') }}">
    <script src="{{ url('mobile/js/jquery-1.8.3.min.js') }}"></script>
    <script src="{{ url('/common/mobile-common/hmt.js') }}"></script>
</head>
<body>
<div class="abouts">
    <div class="wrap-cont clearfix">
        <!--生成-->
        <div class="wrap-cont wrap-cont4">
                <div class="cards clearfix">
                    <div class="wrap-cont wrap-cont2">
                        <div class="bd-info">
                            <p class="dp">
                                <img src="{{ url('mobile/images/dp.png')}}">
                                <span>人脸照片上传</span>
                            </p>
                        </div>
                        <div class="tel-info">
                            <form id="form">
                            <p style="position: relative;" class="captcha">
                                <input type="text" name="std_no" placeholder="请输入学生证号">
                            </p>
                            <p style="position: relative;" class="captcha">
                                <input type="text" name="name" placeholder="请输入姓名">
                            </p>
                            <span class="tx-img-span chang-btn2"   style="text-align: center;display: none">
                                <img src="" id="file_img" style="margin-top: 15px;" width="80" height="80">
                                <input type="hidden" id="input_hidden"  name="img">
						    </span>
                            <p style="position: relative;" class="captcha">
                                <input type="file" id="photo" name="captcha"  class="chgeImg" accept="image/*">
                            </p>
                            <a class="ljbd btnn">提交</a>
                            </form>
                        </div>
                    </div>
        </div>
        <!--end-->
    </div>
</div>
</div>
</body>
<script src="{{ url('/') }}/layer/layer.js"></script>
<script>
    var load;
    $(function(){
        //点击上传头像
        $('.chgeImg').on('change',function() {
            var url = "{{ url('upload/img') }}";
            var id = $(this).attr('id');
            uploadPhoto(id,url);
        })

        function uploadPhoto(id,url){
            var fileObj = document.getElementById(id).files[0];
            var form = new FormData();
            form.append("file", fileObj);
            $.ajax({
                url:url,
                type:'post',
                data:form,
                processData: false,
                cache: false,
                contentType: false,
                success:function(data){
                    if(data.success){
                        $("#file_img").attr("src","{{ config('config.picHostPrefix')}}"+data.data);
                        $(".tx-img-span").show();
                        $('[name=img]').val(data.data);
                        console.log(data);
                    } else {
                        layer.alert(data.msg);
                        location.reload();
                    }
                }
            });
        }

        $(".ljbd").click(function(e){
            var data = $("#form").serialize();
            e.preventDefault();
            $.ajax({
                url:"{{ url('wap/face/faceSave') }}",
                type:"post",
                dataType:"json",
                data:data,
                success:function(data){
                    layer.close(load);
                    layer.msg(data.msg);
                    location.href = href;
                },
                error:function(data){
                    layer.close(load);
                    layer.msg(data.responseJSON.msg,{icon:5});
                }
            })
        })
    });
</script>
</html>
